import request from '@/utils/request'

/*
*获取车辆分页数据的接口
*  */
export const fetchVehicleListAPI = (params) => {
  return request({
    url: '/manager/truck/page',
    method: 'GET',
    params
  })
}

/*
* 统计车辆停用和可用的接口
*  */
export const getVehicleListCountAPI = () => {
  return request({
    url: '/manager/count',
    method: 'GET'
  })
}

/*
*
* 删除车辆的接口
*  */
export const deleteVehicleAPI = (id) => {
  return request({
    url: `/manager/del/${id}`,
    method: 'DELETE'
  })
}

/*
* 新增车辆的接口
*  */
export const addVehicleAPI = (data) => {
  return request({
    url: '/manager/truck',
    method: 'POST',
    data
  })
}

/*
* 获取所有司机的接口
* */
export const fetchDriverAllAPI = () => {
  return request({
    url: '/manager/driver/page',
    method: 'GET',
    params: {
      page: 1,
      pageSize: 100
    }
  })
}

/*
*
* 获取车辆所绑定的司机接口
*  */
export const fetchDriverByIdAPI = (truckId) => {
  return request({
    url: `/manager/bindingDrivers/${truckId}`,
    method: 'GET'
  })
}

/*
*
* 车辆绑定司机的接口
*  */
export const bindDriverAPI = (data) => {
  return request({
    url: '/manager/truck/truckDrivers',
    method: 'POST',
    data
  })
}

/*
* 启用车辆的接口
*  */
export const startVehicleAPI = (id) => {
  return request({
    url: `/manager/enable/${id}`,
    method: 'PUT'
  })
}

/*
* 停用车辆的接口
*  */
export const endVehicleAPI = (id) => {
  return request({
    url: `/manager/disable/${id}`,
    method: 'PUT'
  })
}

/*
*
* 获取车辆详情的接口
*  */
export const fetchVehicleDetailAPI = (id) => {
  return request({
    url: `/manager/truck/${id}`,
    method: 'GET'
  })
}

/*
*
* 编辑车辆的接口
*  */
export const editVehicleAPI = (data) => {
  return request({
    url: `/manager/truck/${data.id}`,
    method: 'PUT',
    data
  })
}

/*
*
* 更新车辆信息的接口
*  */

export const updateVehicleAPI = (data) => {
  return request({
    url: `/manager/truck/${data.id}`,
    method: 'PUT',
    data
  })
}
